<template>
  <BasicForm @register="registerForm" @submit="handleSubmit" />
</template>

<script lang="ts" setup>
  import BasicForm from "/@/components/Form/src/BasicForm.vue";
  import { useForm } from "/@/components/Form";
  import { onMounted } from "vue";
  import { personalSummaryFormSchema } from "../task.data";
  import { defaultFormSettings } from "/@/hooks/core/useDefault";
  import { useMessage } from "/@/hooks/web/useMessage";
  import { getRemarkApi, setSummaryApi } from "/@/api/core/internInfo";

  const [registerForm, { setFieldsValue }] = useForm({
    ...defaultFormSettings,
    schemas: personalSummaryFormSchema,
  });

  const { createMessage } = useMessage();

  async function handleSubmit(value) {
    await setSummaryApi(value.personalSummary);
    createMessage.success("设置个人总结成功");
  }

  onMounted(async () => {
    const { personalSummary } = await getRemarkApi();
    await setFieldsValue({ personalSummary });
  });
</script>
